<!--
 * @Author: cqg
 * @Date: 2021-07-09 16:32:52
 * @LastEditTime: 2021-07-09 19:28:57
 * @Description: file content
 * @LastEditors: cqg
-->
<template>
  <el-dialog title="人文关怀" :visible.sync="dialogVisible" class="basic-from" @close="resetForm" append-to-body>
    <el-collapse v-model="activeName">
      <el-collapse-item title="基本信息" name="0">
        <el-form :model="form" ref="ruleForm" class="form-wrap">
          <el-form-item label="姓名" prop="name">
            <el-input v-model="form.name" disabled />
          </el-form-item>
          <el-form-item label="性别" prop="gender">
            <el-select v-model="form.gender" disabled>
              <el-option v-for=" item in getDict('gender')" :key="item.value" :label="item.label" :value="item.value" />
            </el-select>
          </el-form-item>
          <el-form-item label="证件类型" prop="cardType">
            <el-select v-model="form.cardType" disabled>
              <el-option v-for=" item in getDict('card_type')" :key="item.value" :label="item.label" :value="item.value" />
            </el-select>
          </el-form-item>
          <el-form-item label="证件号" prop="cardId">
            <el-input v-model="form.cardId" disabled />
          </el-form-item>
          <el-form-item label="手机号码" prop="telPhone">
            <el-input v-model="form.telPhone" disabled />
          </el-form-item>
        </el-form>
      </el-collapse-item>
      <el-collapse-item name="1">
        <template slot="title">
          人文关怀措施
          <div style="margin-left: 78%; color:red;" @click.stop="HistoryDialogShow =!HistoryDialogShow">历史评估</div>
        </template>
        <el-form :model="form" :rules="rules" ref="ruleForm" class="form-wrap">
          <el-form-item label="心理评估" prop="slpg" class="full">
            <el-radio-group v-model="form.slpg">
              <el-radio :label="item.value" :key="item.value" v-for="(item,index) in getDict('xlpg')">{{item.label}}</el-radio>
            </el-radio-group>
          </el-form-item>
          <el-form-item label="既往史" class="full">
            <el-input v-model="form.jws" type="textarea" />
          </el-form-item>
          <el-form-item label="宣教、心理疏导" class="full">
            <el-input v-model="form.jtrwghcs" type="textarea" />
          </el-form-item>
          <el-form-item label="具体人文关怀措施" class="full">
            <el-input v-model="form.jtrwghcs" type="textarea" />
          </el-form-item>
          <el-form-item label="特殊药物治疗" class="full">
            <el-input v-model="form.tsywyz" type="textarea" />
          </el-form-item>
        </el-form>
      </el-collapse-item>
    </el-collapse>
    <div class="historyDialog" v-show="HistoryDialogShow">
      <dataList :pageInfo="pager" pure>
        <el-table ref="multipleTable" :data="tableData" border>
          <el-table-column prop="moveStartTime" label="评估日期"></el-table-column>
          <el-table-column prop="moveEndTime" label="评估医生"></el-table-column>
          <!-- <el-table-column prop="moveEndTime" label="操作"></el-table-column> -->
        </el-table>
      </dataList>
    </div>
    <div slot="footer" class="dialog-footer">
      <el-button @click="resetForm">取 消</el-button>
      <el-button type="primary" v-throttle="[submit]">确 定</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { listRoom, getCare, houseEdit } from "@/views/yq-personnel/api/checkIn.js";
export default {
  name: 'infoEdit',
  inject: ["initList"],
  data () {
    return {
      // 请求参数
      params: {
        current: 1,
        size: 20,
        keyword: "",
      },
      // 分页
      pager: {
        total: 0, // 总页数
        current: 1, // 当前页数
        size: 20, // 每页显示多少条
      },
      dialogVisible: false,
      HistoryDialogShow: false,
      activeName: ['0', '1'],
      //房间列表
      form: {
        tsywyz: '',
        jtrwghcs: '',
        jws: '',
        personId: '',
      },
      tableData: [],
      rules: {
        // tsywyz: [{ required: true, message: '请输入隔离天数', trigger: 'blur' }],
        // jtrwghcs: [{ required: true, message: '请输入隔离天数', trigger: 'blur' }],
        // jws: [{ required: true, message: '请输入隔离天数', trigger: 'blur' }],
      }
    }
  },
  watch: {

    HistoryDialogShow (v) {
      if (v) {

      }
    }
  },
  methods: {
    //修改房间弹窗监听事件
    async show (row) {
      this.form = { ...this.form, ...row }
      this.dialogVisible = true
      this.queryData()
    },
    // 数据请求
    async queryData (params = {}) {
      let requestData = { ...this.params, ...params };
      let res = await getCare(this.form.personId)
      const { current, size, total, records } = res.data.data;
      this.tableData = records;
      this.params = requestData;
      this.pager = { total, current, size };

    },
    //提交修改
    submit () {
      this.$refs.ruleForm.validate(async (valid) => {
        if (valid) {
          let rps = await houseEdit(this.form)
          this.initList({ current: 1, })
          this.$message.success('提交成功！');
          this.dialogVisible = false
        } else
          return false;
      });
    },
    resetForm () {
      this.dialogVisible = false
      this.$refs.ruleForm.resetFields();
    }
  }
}
</script>

<style lang="scss" scoped>
.historyDialog {
  position: absolute;
  overflow: hidden;
  width: 340px;
  background-color: white;
  border: 1px solid black;
  padding: 15px;
  right: -320px;
  top: 0;
  height: 100%;
}
/deep/.el-collapse-item__header {
  font-weight: 700;
  padding: 7px;
  border-radius: 5px;
  background-color: #cce1f1;
  opacity: 0.9;
  color: blue;
  margin-bottom: 20px;
}
/deep/.el-dialog__body {
  height: 580px;
  overflow-y: auto;
}
</style>